package com.deep.stream.service;

/**
 * @author dell
 * @create 2022/7/28 8:26
 */

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class StreamService {

    @Autowired
    @Qualifier(OutputInterface.OUTPUT1)
    MessageChannel channel1;

    public void sendMessage(String channel) {
        String message = "Send Message Manually,From Channel:" + channel;
        log.info("Send Message from channel:" + channel);
        switch (channel) {
            case OutputInterface.OUTPUT1:
                channel1.send(MessageBuilder.withPayload(message).build());
                return;
            default:
                log.info("参数错误: " + channel);
                return;
        }
    }
}